<?php
namespace app\index\model;

use app\index\BaseController;
use think\facade\Session;
use think\Model;

class Address extends Model
{
    public static function addressList()
    {
        $list = Address::alias('a')
            ->where('a.uid','=',Session::get('user'))
            ->field('a.*,c.name as asheng,cc.name as acity,ccc.name as aquyu')
            ->join('china_city c','c.id=a.sheng')
            ->join('china_city cc','cc.id=a.city')
            ->join('china_city ccc','ccc.id=a.quyu')
            ->select();
        return $list;
    }
    public static function addAddressInfo($data)
    {
        try{
            $res = Address::insert($data);
            $msg = '成功';
        }catch (\Exception $e){
            $res = false;
            $msg = $e->getMessage();
        }
        return [$res,$msg];
    }
    public static function editAddressInfo($post)
    {
        try{
            $res = Address::update($post);
        }catch (\Exception $e){
            $res = false;
        }
        return $res;
    }

}